package com.jcvision.mms.webservice;

import javax.jws.WebService;

import org.apache.log4j.Logger;

import com.jcvision.mms.dao.SubscriberDao;
import com.jcvision.mms.dao.SysUserDao;
import com.jcvision.mms.model.Subscriber;

@WebService
public class OrderNotify {
	
	private static Logger logger = Logger.getLogger(OrderNotify.class);
	public static final int RESULTCODE_SUCCESS = 0;
	public static final int RESULTCODE_FAIL = 1;
	
	public OrderRelationUpdateNotifyRsp orderRelationUpdateNotify(OrderRelationUpdateNotifyReq req) {
		OrderRelationUpdateNotifyRsp rsp = null;
		String log = "收到订购关系通知请求";
		if (req != null)
			log += ",ID:" + req.getRecordSequenceId() + "内容:" + req.getContent();
		logger.info(log);
		
		if (req == null) {
			
		} else {
			rsp = new OrderRelationUpdateNotifyRsp();
			rsp.setRecordSequenceId(req.getRecordSequenceId());
			try {
				Subscriber record = new Subscriber();
				record.setMobileNumber(req.getContent());
				SubscriberDao dao = new SubscriberDao();
				int count = dao.insert(record);
				if (count > 0){
					rsp.setResultCode(RESULTCODE_SUCCESS);
				}
			} catch (Exception e) {
				logger.warn(e);
			}
			rsp.setResultCode(RESULTCODE_FAIL);
		}
		return rsp;
	}
	
}
